package com.umakr.ax.opt.web;

import com.umakr.ax.common.model.RadioStation;
import com.umakr.ax.core.base.AbstractController;
import com.umakr.ax.opt.service.RadioStationOptService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 * 电台信息  前端控制器
 * </p>
 *
 * @author Umakr-Code-Generator
 * @since 2017-12-30
 */
@Controller
@RequestMapping("/api/opt/radioStation")
public class RadioStationOptController extends AbstractController {
    @Autowired
    RadioStationOptService radioStationOptService;


    @ApiOperation(value = "电台里表")
    @GetMapping(value = "/listRadioStation")
    @ResponseBody
    public Object listRadioStation(ModelMap modelMap,@RequestParam(name = "rsName") String rsName) {
        return setSuccessModelMap(modelMap,radioStationOptService.listRadioStation(rsName));
    }

    @ApiOperation(value = "删除电台")
    @GetMapping("/updateRadioStationStatus")
    @ResponseBody
    public Object updateRadioStationStatus(ModelMap modelMap,@RequestParam(name = "id") Long id,@RequestParam(name = "status") Integer status) {
        return setSuccessModelMap(modelMap,radioStationOptService.updateRadioStationStatus(id,status));
    }

    @ApiOperation(value = "新增或者更新电台")
    @GetMapping("/saveOrUpdateRadioStation")
    @ResponseBody
    public Object saveOrUpdateRadioStation(ModelMap modelMap,RadioStation radioStation,String username,String password) {
        return setSuccessModelMap(modelMap,radioStationOptService.saveOrUpdateRadioStation(radioStation,username,password));
    }

    @ApiOperation(value = "电台详情")
    @GetMapping(value = "/getRadioStationByRsId")
    @ResponseBody
    public Object getRadioStationByRsId(ModelMap modelMap,@RequestParam(name = "rsId") Long rsId) {
        return setSuccessModelMap(modelMap,radioStationOptService.getRadioStationByRsId(rsId));
    }
}